Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate CaptureArbitrumStorageGet/Set into the prestate tracer #2602

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

ganeshvanahalli
Copy link
Contributor

@ganeshvanahalli ganeshvanahalli commented Aug 22, 2024

This PR implements CaptureArbitrumStorage[Get]Set methods for prestateTracer capturing changes that ArbOS makes to storage outside EVM execution, these weren't picked up by the prestateTracer before.

Arbos Storage object calls RecordStorage[Get]Set functions to capture tracing of reads and writes of key-value pairs, meaning the SLOAD/SSTORE opcodes tracing in these functions during scenario TracingDuringEVM has no impact at all as the caller address (scope.Contract) and the key being passed don't associate with each other, instead the key corresponds to types.ArbosStateAddress.

To solve this issue, we currently call CaptureArbitrumStorage[Get]Set regardless of the tracing scenario and call opcode tracing additionally if the scenario is TracingDuringEVM to preserve functionality of other tracers that haven't yet implemented CaptureArbitrumStorage... methods. Notice that SLOAD/SSTORE opcode tracing has no effect on prestate tracer due to the above stated issue and calling CaptureArbitrumStorage... methods first yields correct results.

Pulls in geth- OffchainLabs/go-ethereum#352
Resolves NIT-2733

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Aug 22, 2024
@ganeshvanahalli ganeshvanahalli changed the base branch from master to update-gethpin-v1.14.0 August 22, 2024 14:39
@ganeshvanahalli ganeshvanahalli marked this pull request as ready for review August 22, 2024 14:56
@ganeshvanahalli ganeshvanahalli changed the title Integrate capturearbitrumstoragegetset prestatetracer Integrate CaptureArbitrumStorageGet/Set into the prestate tracer Aug 22, 2024
Base automatically changed from update-gethpin-v1.14.0 to master November 6, 2024 01:09
system_tests/debugapi_test.go Outdated Show resolved Hide resolved
system_tests/debugapi_test.go Outdated Show resolved Hide resolved
system_tests/debugapi_test.go Show resolved Hide resolved
system_tests/debugapi_test.go Outdated Show resolved Hide resolved
system_tests/debugapi_test.go Show resolved Hide resolved
@@ -141,9 +140,16 @@ func TestPrestateTracerArbitrumStorage(t *testing.T) {
hourNow := (time.Now().Unix() - programs.ArbitrumStartTime) / 3600
hourActivatedFromTrace := arbmath.BytesToUint24(postData[8:11])
// #nosec G115
assert(uint64(hourActivatedFromTrace) == uint64(hourNow), nil, "wrong activated time in trace")
if !(uint64(hourActivatedFromTrace) == uint64(hourNow)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: this if is not needed

Copy link
Contributor Author

@ganeshvanahalli ganeshvanahalli Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had left it there thinking it signifies we are looking for equality check (most cases) here. But we kind need to have two checks anyway as we should check if math.Abs(float64(hourActivatedFromTrace)-float64(hourNow)) is either 0 or 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants